Repository navigation
fix(spinbox): redesign indicator background with combined container - #752
Conversation
Reviewer's GuideUIReplace the SpinBox indicator’s separate active and inactive rendering with ToolButtons and per-indicator background halves, including the dark-mode bottom shadow and disabled-icon opacity.
ConfigurationDefine the combined indicator’s width, spacing, background colors, corner radius, and dark-mode inner-shadow color in the SpinBox style.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 8 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="qt6/src/qml/SpinBoxIndicator.qml" line_range="30" />
<code_context>
- implicitHeight: spinBox.activeFocus ? spinBox.implicitHeight / 2 : DS.Style.spinBox.indicator.height
+ // The whole indicator area (up + down) is the input field height minus 4,
+ // so each half is (height - 4) / 2, leaving a 2px margin on top/bottom.
+ implicitHeight: (spinBox.implicitHeight - 4) / 2
opacity: D.ColorSelector.controlState === D.DTK.DisabledState ? 0.4 : 1
</code_context>
<issue_to_address>
**Indicator sizing becomes unreliable**
When a SpinBox uses its default up/down indicators, `SpinBoxIndicator.implicitHeight` reads `spinBox.implicitHeight`, which includes the indicators’ own implicit heights, so QML reports a binding loop and indicator sizing becomes unreliable.
Derive each indicator’s implicit height from a value that does not depend on `spinBox.implicitHeight`.
</issue_to_address>
### Comment 2
<location path="qt6/src/qml/SpinBoxIndicator.qml" line_range="30" />
<code_context>
- implicitHeight: spinBox.activeFocus ? spinBox.implicitHeight / 2 : DS.Style.spinBox.indicator.height
+ // The whole indicator area (up + down) is the input field height minus 4,
+ // so each half is (height - 4) / 2, leaving a 2px margin on top/bottom.
+ implicitHeight: (spinBox.implicitHeight - 4) / 2
opacity: D.ColorSelector.controlState === D.DTK.DisabledState ? 0.4 : 1
</code_context>
<issue_to_address>
**Indicators leave dead space**
When a caller assigns a SpinBox height different from its implicit height, `SpinBoxIndicator.implicitHeight` sizes the buttons from `spinBox.implicitHeight`, but their anchors and combined background use the actual SpinBox height, leaving the indicators undersized and parts of the area unclickable.
Size each indicator from the SpinBox’s actual height so the buttons fill the intended halves of the background.
</issue_to_address>
### Comment 3
<location path="qt6/src/qml/SpinBoxIndicator.qml" line_range="33" />
<code_context>
- mode: control.D.ColorSelector.controlState
- theme: control.D.ColorSelector.controlTheme
- fallbackToQIcon: false
+ Button {
+ id: btn
+ anchors.fill: parent
</code_context>
<issue_to_address>
**Holding an arrow changes one step**
When a user holds an arrow indicator, the filling `Button` consumes the arrow press, but its `onClicked` handler calls `increase()` or `decrease()` only once on release and auto-repeat is not enabled. Holding an arrow therefore changes the value by one step instead of repeating.
Enable auto-repeat for the arrow button and repeat the corresponding spin-box operation while it remains pressed.
</issue_to_address>
### Comment 4
<location path="qt6/src/qml/SpinBox.qml" line_range="75" />
<code_context>
property int height: 36
property int spacing: 10
+ property int indicatorSpacing: 2
property QtObject indicator: QtObject {
- property int width: 24
</code_context>
<issue_to_address>
**Combined background is hidden**
`indicatorContainer.z: -1` places its Control background below the SpinBox background; `EditPanel` paints an opaque fill, so the combined indicator background is obscured and users see no indicator-area background.
Stack the combined background above the SpinBox's opaque background while keeping it behind the indicator buttons.
</issue_to_address>
### Comment 5
<location path="qt6/src/qml/SpinBox.qml" line_range="73-83" />
<code_context>
+ }
+ width: DS.Style.spinBox.indicator.width
+ height: control.height - 2 * DS.Style.spinBox.indicatorContainerVMargin
+ visible: up.indicator || down.indicator
+ z: -1
+
+ property D.Palette indicatorBackground: DS.Style.spinBox.indicatorBackground
+ property D.Palette indicatorInnerShadow: DS.Style.spinBox.indicatorInnerShadow
+
+ background: Item {
+ Rectangle {
+ anchors.fill: parent
+ radius: 4
+ color: indicatorContainer.D.ColorSelector.indicatorBackground
+ }
+
</code_context>
<issue_to_address>
**Custom indicator gains built-in backdrop**
When a caller replaces either `up.indicator` or `down.indicator` with a custom item, `indicatorContainer` remains visible and paints the combined background behind a replacement indicator, so the caller's custom indicator no longer replaces the default indicator treatment.
Tie the combined background to the default indicators, or provide callers a way to disable or customize it when replacing an indicator slot.
</issue_to_address>
### Comment 6
<location path="qt6/src/qml/SpinBox.qml" line_range="68" />
<code_context>
+ id: indicatorContainer
+ anchors {
+ right: control.right
+ rightMargin: DS.Style.spinBox.indicatorSpacing
+ verticalCenter: control.verticalCenter
+ }
</code_context>
<issue_to_address>
**Text ends too far from indicators**
When one or both indicators are present, `rightPadding` reserves `indicator.width + spinBox.spacing` (20 + 10 px), while the indicators sit 2 px from the right edge, so the text ends 8 px before the indicator area and leaves an oversized gap.
Set `rightPadding` to match the indicator area’s 2 px right spacing.
</issue_to_address>
### Comment 7
<location path="qt6/src/qml/SpinBoxIndicator.qml" line_range="42-43" />
<code_context>
+ rightPadding: 0
+ icon {
+ name: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? "arrow_ordinary_up" : "arrow_ordinary_down"
+ width: DS.Style.spinBox.indicator.focusIconSize
+ height: DS.Style.spinBox.indicator.focusIconSize
}
- }
</code_context>
<issue_to_address>
**Idle arrows render too small**
When the spin box is displayed, especially while it is not focused, `Button.icon` always uses `focusIconSize` (10 px), replacing the unfocused 24 px source size; configured indicator icon sizes also no longer affect the control, so the arrows render too small.
Use the configured icon size for unfocused indicators and reserve `focusIconSize` for the focused state.
Also at `qt6/src/qml/SpinBoxIndicator.qml:30`.
</issue_to_address>
### Comment 8
<location path="qt6/src/qml/SpinBoxIndicator.qml" line_range="33" />
<code_context>
- mode: control.D.ColorSelector.controlState
- theme: control.D.ColorSelector.controlTheme
- fallbackToQIcon: false
+ Button {
+ id: btn
+ anchors.fill: parent
</code_context>
<issue_to_address>
**Disabled arrows are too faint**
When the SpinBox is disabled, the outer indicator and nested `Button` each apply 0.4 opacity, so their opacities multiply and the arrows render at roughly 0.16 opacity instead of 0.4.
Apply the disabled opacity only once, either on the outer indicator or on the nested button.
</issue_to_address>| implicitHeight: spinBox.activeFocus ? spinBox.implicitHeight / 2 : DS.Style.spinBox.indicator.height | ||
| // The whole indicator area (up + down) is the input field height minus 4, | ||
| // so each half is (height - 4) / 2, leaving a 2px margin on top/bottom. | ||
| implicitHeight: (spinBox.implicitHeight - 4) / 2 |
There was a problem hiding this comment.
🟡 Medium · Indicator sizing becomes unreliable
When a SpinBox uses its default up/down indicators, SpinBoxIndicator.implicitHeight reads spinBox.implicitHeight, which includes the indicators’ own implicit heights, so QML reports a binding loop and indicator sizing becomes unreliable.
Derive each indicator’s implicit height from a value that does not depend on spinBox.implicitHeight.
Prompt for AI agents
In `qt6/src/qml/SpinBoxIndicator.qml` at line 30:
**Indicator sizing becomes unreliable**
When a SpinBox uses its default up/down indicators, `SpinBoxIndicator.implicitHeight` reads `spinBox.implicitHeight`, which includes the indicators’ own implicit heights, so QML reports a binding loop and indicator sizing becomes unreliable.
Derive each indicator’s implicit height from a value that does not depend on `spinBox.implicitHeight`.| implicitHeight: spinBox.activeFocus ? spinBox.implicitHeight / 2 : DS.Style.spinBox.indicator.height | ||
| // The whole indicator area (up + down) is the input field height minus 4, | ||
| // so each half is (height - 4) / 2, leaving a 2px margin on top/bottom. | ||
| implicitHeight: (spinBox.implicitHeight - 4) / 2 |
There was a problem hiding this comment.
🟡 Medium · Indicators leave dead space
When a caller assigns a SpinBox height different from its implicit height, SpinBoxIndicator.implicitHeight sizes the buttons from spinBox.implicitHeight, but their anchors and combined background use the actual SpinBox height, leaving the indicators undersized and parts of the area unclickable.
Size each indicator from the SpinBox’s actual height so the buttons fill the intended halves of the background.
Prompt for AI agents
In `qt6/src/qml/SpinBoxIndicator.qml` at line 30:
**Indicators leave dead space**
When a caller assigns a SpinBox height different from its implicit height, `SpinBoxIndicator.implicitHeight` sizes the buttons from `spinBox.implicitHeight`, but their anchors and combined background use the actual SpinBox height, leaving the indicators undersized and parts of the area unclickable.
Size each indicator from the SpinBox’s actual height so the buttons fill the intended halves of the background.| mode: control.D.ColorSelector.controlState | ||
| theme: control.D.ColorSelector.controlTheme | ||
| fallbackToQIcon: false | ||
| Button { |
There was a problem hiding this comment.
🟡 Medium · Holding an arrow changes one step
When a user holds an arrow indicator, the filling Button consumes the arrow press, but its onClicked handler calls increase() or decrease() only once on release and auto-repeat is not enabled. Holding an arrow therefore changes the value by one step instead of repeating.
Enable auto-repeat for the arrow button and repeat the corresponding spin-box operation while it remains pressed.
Prompt for AI agents
In `qt6/src/qml/SpinBoxIndicator.qml` at line 33:
**Holding an arrow changes one step**
When a user holds an arrow indicator, the filling `Button` consumes the arrow press, but its `onClicked` handler calls `increase()` or `decrease()` only once on release and auto-repeat is not enabled. Holding an arrow therefore changes the value by one step instead of repeating.
Enable auto-repeat for the arrow button and repeat the corresponding spin-box operation while it remains pressed.| height: control.height - 2 * DS.Style.spinBox.indicatorContainerVMargin | ||
| visible: up.indicator || down.indicator | ||
| z: -1 | ||
|
|
There was a problem hiding this comment.
🟠 High · Combined background is hidden
indicatorContainer.z: -1 places its Control background below the SpinBox background; EditPanel paints an opaque fill, so the combined indicator background is obscured and users see no indicator-area background.
Stack the combined background above the SpinBox's opaque background while keeping it behind the indicator buttons.
Prompt for AI agents
In `qt6/src/qml/SpinBox.qml` at line 75:
**Combined background is hidden**
`indicatorContainer.z: -1` places its Control background below the SpinBox background; `EditPanel` paints an opaque fill, so the combined indicator background is obscured and users see no indicator-area background.
Stack the combined background above the SpinBox's opaque background while keeping it behind the indicator buttons.| visible: up.indicator || down.indicator | ||
| z: -1 | ||
|
|
||
| property D.Palette indicatorBackground: DS.Style.spinBox.indicatorBackground | ||
| property D.Palette indicatorInnerShadow: DS.Style.spinBox.indicatorInnerShadow | ||
|
|
||
| background: Item { | ||
| Rectangle { | ||
| anchors.fill: parent | ||
| radius: 4 | ||
| color: indicatorContainer.D.ColorSelector.indicatorBackground |
There was a problem hiding this comment.
🟡 Medium · Custom indicator gains built-in backdrop
When a caller replaces either up.indicator or down.indicator with a custom item, indicatorContainer remains visible and paints the combined background behind a replacement indicator, so the caller's custom indicator no longer replaces the default indicator treatment.
Tie the combined background to the default indicators, or provide callers a way to disable or customize it when replacing an indicator slot.
Prompt for AI agents
In `qt6/src/qml/SpinBox.qml` at lines 73-83:
**Custom indicator gains built-in backdrop**
When a caller replaces either `up.indicator` or `down.indicator` with a custom item, `indicatorContainer` remains visible and paints the combined background behind a replacement indicator, so the caller's custom indicator no longer replaces the default indicator treatment.
Tie the combined background to the default indicators, or provide callers a way to disable or customize it when replacing an indicator slot.| id: indicatorContainer | ||
| anchors { | ||
| right: control.right | ||
| rightMargin: DS.Style.spinBox.indicatorSpacing |
There was a problem hiding this comment.
🟡 Medium · Text ends too far from indicators
When one or both indicators are present, rightPadding reserves indicator.width + spinBox.spacing (20 + 10 px), while the indicators sit 2 px from the right edge, so the text ends 8 px before the indicator area and leaves an oversized gap.
Set rightPadding to match the indicator area’s 2 px right spacing.
Prompt for AI agents
In `qt6/src/qml/SpinBox.qml` at line 68:
**Text ends too far from indicators**
When one or both indicators are present, `rightPadding` reserves `indicator.width + spinBox.spacing` (20 + 10 px), while the indicators sit 2 px from the right edge, so the text ends 8 px before the indicator area and leaves an oversized gap.
Set `rightPadding` to match the indicator area’s 2 px right spacing.| width: DS.Style.spinBox.indicator.focusIconSize | ||
| height: DS.Style.spinBox.indicator.focusIconSize |
There was a problem hiding this comment.
🟡 Medium · Idle arrows render too small
When the spin box is displayed, especially while it is not focused, Button.icon always uses focusIconSize (10 px), replacing the unfocused 24 px source size; configured indicator icon sizes also no longer affect the control, so the arrows render too small.
Use the configured icon size for unfocused indicators and reserve focusIconSize for the focused state.
Also at qt6/src/qml/SpinBoxIndicator.qml:30.
Prompt for AI agents
In `qt6/src/qml/SpinBoxIndicator.qml` at lines 42-43:
**Idle arrows render too small**
When the spin box is displayed, especially while it is not focused, `Button.icon` always uses `focusIconSize` (10 px), replacing the unfocused 24 px source size; configured indicator icon sizes also no longer affect the control, so the arrows render too small.
Use the configured icon size for unfocused indicators and reserve `focusIconSize` for the focused state.
Also at `qt6/src/qml/SpinBoxIndicator.qml:30`.9f5ef91 to
d3d1c77
Compare
|
test |
ffc192b to
1a4ba16
Compare
8cff3b3 to
bcf44d1
Compare
bcf44d1 to
54afc1f
Compare
| @@ -1,4 +1,4 @@ | |||
| // SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd. | |||
There was a problem hiding this comment.
当文件修改只有这种格式和license,就不用修改提交,
- Remove individual background from up/down indicator buttons - Each indicator renders its own half of the combined background (up: rounded top corners, down: rounded bottom corners) - Background width 20px, height = spinbox height - 4px, 4px corner radius - Spacing between input field and indicator area: 2px - Background color: light mode rgba(0,0,0,0.15), dark mode rgba(0,0,0,0.2) - Dark mode only: 1px inner shadow at bottom edge (down indicator only), color rgba(0,0,0,0.4) - Simplify SpinBoxIndicator: remove Loader-based inactive/active switching and ItemViewport, use ToolButton (background: null) instead - Disabled state only dims the icon, background stays unchanged - Indicator width: 24 -> 20
54afc1f to
f5d95f5
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['无语法逻辑问题'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['移除 background Rectangle 中冗余的 radius 属性,仅保留 topLeftRadius/topRightRadius/bottomLeftRadius/bottomRightRadius 四个独立属性'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无性能问题'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无安全问题'] 💡 改进建议代码示例// SpinBoxIndicator.qml - 移除冗余的 radius 属性 background: Rectangle {
// 移除: radius: DS.Style.spinBox.indicatorContainerRadius
color: control.D.ColorSelector.indicatorBackground
topLeftRadius: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0
topRightRadius: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0
bottomLeftRadius: direction === SpinBoxIndicator.IndicatorDirection.DownIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0
bottomRightRadius: direction === SpinBoxIndicator.IndicatorDirection.DownIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0
Loader {
active: D.DTK.themeType === D.ApplicationHelper.DarkType && direction === SpinBoxIndicator.IndicatorDirection.DownIndicator
anchors.fill: parent
sourceComponent: BoxInsetShadow {
shadowBlur: 1
shadowOffsetY: -1
spread: 0
shadowColor: control.D.ColorSelector.indicatorInnerShadow
cornerRadius: DS.Style.spinBox.indicatorContainerRadius
}
}
}本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, iCancely The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
acdb33d
into
linuxdeepin:v25-flowstyle
修改内容 / Changes
中文
重新设计 SpinBox 上下箭头指示器的背景样式:
rgba(0,0,0,0.15),深色模式rgba(0,0,0,0.2)rgba(0,0,0,0.4)English
Redesign the SpinBox up/down indicator background style:
rgba(0,0,0,0.15), dark modergba(0,0,0,0.2)rgba(0,0,0,0.4)截图 / Screenshots
浅色模式 / Light mode:
深色模式 / Dark mode: